<template>
  <div class="container">
    <div>
      <el-row :gutter="25">
        <el-col :span="6">
          <el-form ref="form" :model="form" label-width="120px">
            <el-form-item label="公厕名称：">
              <el-input
                v-model="select.name"
                placeholder="请输入公厕名称"
                style="width: 150px"
              ></el-input>
            </el-form-item>
          </el-form>
        </el-col>
        <el-col :span="14">
          <el-form ref="form" :model="form" style="float: left">
            <el-form-item>
              <el-button size="mini" type="primary" @click="screeningData"
                >查 询</el-button
              >
              <el-button size="mini" type="success" @click="handleAdd"
                >新 增</el-button
              >

              <el-button style="padding: 0; border: 0">
                <el-upload
                  action="/上传文件的接口"
                  :on-change="onChange"
                  :auto-upload="false"
                  :show-file-list="false"
                  accept=".xls, .xlsx"
                  class="upload"
                >
                  <el-button size="mini" type="success">导 入</el-button>
                </el-upload>
              </el-button>
              <el-button size="mini" type="warning" @click="exportExcel"
                >导 出</el-button
              >
            </el-form-item>
          </el-form>
        </el-col>
      </el-row>
    </div>
    <el-table
      :data="
        tableData.slice((currentPage - 1) * pageSize, currentPage * pageSize)
      "
      @row-dblclick="dblClickRow"
      highlight-current-row
    >
      <el-table-column
        prop="ID"
        label="公厕编号"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="NAME"
        label="公厕名称"
        align="center"
        width="100"
      ></el-table-column>
      <!-- <el-table-column  prop="LONGITUDE" label="经度" align="center" ></el-table-column> -->
      <!-- <el-table-column  prop="LATITUDE" label="纬度" align="center" ></el-table-column> -->
      <el-table-column
        prop="LOCATION"
        label="位置"
        align="center"
        width="150"
      ></el-table-column>
      <!-- <el-table-column  prop="CLIENT_NO" label="区域ID" align="center" ></el-table-column> -->
      <el-table-column
        prop="LEVEL"
        label="公厕级别"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="TYPE"
        label="公厕类型"
        align="center"
        width="100"
      ></el-table-column>
      <el-table-column
        prop="TIME"
        label="开放时间"
        align="center"
        width="100"
      ></el-table-column>
      <!-- <el-table-column  prop="MDBSL" label="男厕数量" align="center" ></el-table-column>
      <el-table-column  prop="MZBSL" label="男厕坐便数量" align="center" ></el-table-column>
      <el-table-column  prop="XBC" label="男厕小便池数量" align="center" ></el-table-column>
      <el-table-column  prop="FDBSL" label="女厕数量" align="center" ></el-table-column>
      <el-table-column  prop="FZBSL" label="女厕坐便数量" align="center" ></el-table-column> -->
      <el-table-column
        prop="BABYROOM"
        label="母婴室"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="FREEROOM"
        label="无障碍间"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="AREA"
        label="区域数量"
        align="center"
      ></el-table-column>
      <!-- <el-table-column  prop="CREATE_TIME" label="建造时间" align="center" ></el-table-column> -->
      <!-- <el-table-column  prop="UPDATE_TIME" label="改造时间" align="center" ></el-table-column> -->
      <!-- <el-table-column  prop="REMARK" label="备注" align="center" ></el-table-column> -->
      <el-table-column label="照片" align="center">
        <template slot-scope="scope">
          <el-image
            style="width: 45px; height: 45px; margin-top: 5px"
            :src="scope.row.PHOTO"
            @click="bigImage(scope.row)"
          >
            <div slot="error" class="image-slot" style="margin-top: 10px">
              <i class="el-icon-picture-outline"></i>
            </div>
          </el-image>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" width="350">
        <template slot-scope="scope">
          <!-- <el-button type="text" @click="handleEdit(scope.$index, scope.row)"
            >定位</el-button
          > -->
          <el-button type="text" @click="flowrateClick(scope.$index, scope.row)"
            >流量分析</el-button
          >
          <el-button type="text" @click="SearchClick(scope.$index, scope.row)"
            >气体监测</el-button
          >
          <el-button
            type="text"
            @click="compositeClick(scope.$index, scope.row)"
            >综合信息</el-button
          >
          <el-button type="text" @click="handleEdit(scope.$index, scope.row)"
            >编辑</el-button
          >
          <el-button
            type="text"
            @click="handleDelete(scope.$index, scope.row)"
            style="color: red"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <div class="pagination">
      <el-pagination
        background
        layout="total, sizes, prev, pager, next, jumper"
        :current-page="currentPage"
        :page-size="pageSize"
        :total="tableData.length"
        @size-change="handleSizeChange"
        @current-change="handlePageChange"
      ></el-pagination>
    </div>
    <!-- 弹出框 -->
    <el-dialog
      :title="addDialogTitle"
      :visible.sync="isVisibleEdit"
      width="50%"
      :modal="false"
    >
      <el-form ref="form" :model="form" label-width="100px" class="flex">
        <el-form-item label="公厕名称：" class="wid50">
          <el-input
            v-model="form.NAME"
            placeholder="请输入公厕名称"
            class="handle-input mr10"
          ></el-input>
        </el-form-item>
        <el-form-item label="经度：" class="wid50">
          <el-input
            v-model="form.LONGITUDE"
            placeholder="请输入经度"
            class="handle-input mr10"
          ></el-input>
        </el-form-item>
        <el-form-item label="纬度：" class="wid50">
          <el-input
            v-model="form.LATITUDE"
            placeholder="请输入纬度"
            class="handle-input mr10"
          ></el-input>
        </el-form-item>
        <el-form-item label="位置：" class="wid50">
          <el-input
            v-model="form.LOCATION"
            placeholder="请输入位置"
            class="handle-input mr10"
          ></el-input>
        </el-form-item>
        <el-form-item label="组织机构：" class="wid50">
          <el-select
            v-model="form.CLIENT_NO"
            value-key="id"
            placeholder="请选择"
          >
            <el-option
              v-for="item in selectClientInfoList"
              :key="item.CLIENT_NO"
              :label="item.CLIENT_NAME"
              date-name="item.CLIENT_NAME"
              :value="item.CLIENT_NO"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="公厕级别：" class="wid50" v-if="idEdit">
          <el-select v-model="form.LEVEL" placeholder="请选择">
            <el-option
              v-for="item in LEVELdate"
              :key="item.LEVELltitle"
              :label="item.LEVELltitle"
              :value="item.LEVELltitle"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="公厕类型：" class="wid50" v-if="idEdit">
          <el-select v-model="form.TYPE" placeholder="请选择">
            <el-option
              v-for="item in TYPEdate"
              :key="item.TYPEltitle"
              :label="item.TYPEltitle"
              :value="item.TYPEltitle"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="开放日期：" class="wid50" v-if="idEdit">
          <el-date-picker
            v-model="form.TIME"
            type="date"
            placeholder="选择日期"
            value-format="yyyy-MM-dd"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="男厕数量：" class="wid50" v-if="idEdit">
          <el-input
            v-model="form.MDBSL"
            placeholder="请输入男厕数量"
            class="handle-input mr10"
          ></el-input>
        </el-form-item>
        <!-- <el-form-item label="男厕坐便数量：" class="wid50" v-if="idEdit">
          <el-input
            v-model="form.MZBSL"
            placeholder="请输入男厕坐便数量"
            class="handle-input mr10"
          ></el-input>
        </el-form-item> -->
        <!-- <el-form-item label="男厕小便池数量：" class="wid50" v-if="idEdit">
          <el-input
            v-model="form.XBC"
            placeholder="请输入男厕小便池数量"
            class="handle-input mr10"
          ></el-input>
        </el-form-item> -->
        <el-form-item label="女厕数量：" class="wid50" v-if="idEdit">
          <el-input
            v-model="form.FDBSL"
            placeholder="请输入女厕数量"
            class="handle-input mr10"
          ></el-input>
        </el-form-item>
        <!-- <el-form-item label="女厕坐便数量：" class="wid50" v-if="idEdit">
          <el-input
            v-model="form.FZBSL"
            placeholder="请输入女厕坐便数量"
            class="handle-input mr10"
          ></el-input>
        </el-form-item> -->
        <el-form-item label="母婴室有无：" class="wid50" v-if="idEdit">
          <el-select v-model="form.BABYROOM" placeholder="请选择">
            <el-option
              v-for="item in expireData"
              :key="item.expireTitle"
              :label="item.expireTitle"
              :value="item.expireTitle"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="无障碍间有无：" class="wid50" v-if="idEdit">
          <el-select v-model="form.FREEROOM" placeholder="请选择">
            <el-option
              v-for="item in expireData"
              :key="item.expireTitle"
              :label="item.expireTitle"
              :value="item.expireTitle"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="区域数量：" class="wid50" v-if="idEdit">
          <el-input
            v-model="form.AREA"
            placeholder="请输入区域数量"
            class="handle-input mr10"
          ></el-input>
        </el-form-item>
        <el-form-item label="建造时间：" class="wid50" v-if="idEdit">
          <el-date-picker
            v-model="form.CREATE_TIME"
            type="date"
            placeholder="选择日期"
            value-format="yyyy-MM-dd"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="改造时间：" class="wid50" v-if="idEdit">
          <el-date-picker
            v-model="form.UPDATE_TIME"
            type="date"
            placeholder="选择日期"
            value-format="yyyy-MM-dd"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="备注：" class="wid50" v-if="idEdit">
          <el-input
            v-model="form.REMARK"
            placeholder="请输入备注"
            class="handle-input mr10"
          ></el-input>
        </el-form-item>
        <el-form-item label="照片：" class="wid50" v-if="idEdit">
          <el-button size="mini" type="success" @click="clickVehicle">
            <span v-if="this.PHOTOUrl">重新上传</span>
            <span v-else>上传图片</span>
          </el-button>
          <span style="margin-left: 50px">{{ this.PHOTOUrl }}</span>
          <input
            type="file"
            ref="VehicleFile"
            style="display: none"
            accept="image/gif, image/jpeg"
            @change="changeVehicle"
          />
        </el-form-item>
      </el-form>

      <span slot="footer" class="dialog-footer">
        <el-button @click="isVisibleEdit = false">取 消</el-button>
        <el-button type="primary" @click="handleSubmit()">确 定</el-button>
      </span>
    </el-dialog>
    <!-- 流量分析弹出框 -->
    <el-dialog
      :title="addDialogTitle"
      :visible.sync="isVisibleFlowrate"
      width="1200px"
      :modal="false"
    >
      <el-descriptions class="margin-top" :title="form.NAME" :column="4" border>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-s-unfold"></i>
            公厕级别
          </template>
          {{ form.LEVEL }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-s-grid"></i>
            公厕类型
          </template>
          {{ form.TYPE }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-office-building"></i>
            位置
          </template>
          {{ form.LOCATION }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-star-off"></i>
            满意度
          </template>
          <i class="el-icon-star-on"></i><i class="el-icon-star-on"></i
          ><i class="el-icon-star-on"></i><i class="el-icon-star-on"></i
          ><i class="el-icon-star-on"></i>
        </el-descriptions-item>
      </el-descriptions>
      <el-divider></el-divider>
      <el-descriptions class="margin-top" title="实时人流量" :column="2" border>
        <el-descriptions-item label="今日总人数">
          <el-tag effect="dark">35</el-tag>
        </el-descriptions-item>
        <el-descriptions-item label="实时占用数">
          <el-tag effect="dark" type="warning">3</el-tag>
        </el-descriptions-item>
      </el-descriptions>
      <el-descriptions class="margin-top" :column="4" border>
        <el-descriptions-item label="男厕数量">
          {{ form.MDBSL }}
        </el-descriptions-item>
        <el-descriptions-item label="占用数"> 1 </el-descriptions-item>
        <el-descriptions-item label="女厕数量">
          {{ form.FDBSL }}
        </el-descriptions-item>
        <el-descriptions-item label="占用数"> 2 </el-descriptions-item>
      </el-descriptions>
      <h4 style="margin: 15px 0">昨日每小时人流量统计</h4>
      <div
        style="width: 1138px; height: 300px; background: #fff"
        id="dyclyhLinedivF"
      ></div>
    </el-dialog>
    <!-- 有害气体监测曲线 -->
    <el-dialog
      title="气体监测"
      :visible.sync="dialogVisible"
      width="1200px"
      :modal="false"
    >
      <el-descriptions
        class="margin-top"
        title="实时空气质量"
        :column="3"
        border
      >
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-sunny"></i>
            温度
          </template>
          10℃
        </el-descriptions-item>

        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-light-rain"></i>
            湿度
          </template>
          <!-- <el-tag  effect="dark" type="success">55%</el-tag> -->
          55%
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-odometer"></i>
            空气质量
          </template>
          <el-tag effect="dark" type="success">优</el-tag>
        </el-descriptions-item>
      </el-descriptions>
      <h4 style="margin: 15px 0">过去24小时内恶臭气体监测曲线图</h4>
      <div
        style="width: 1138px; height: 400px; background: #fff"
        id="dyclyhLinediv"
      ></div>
    </el-dialog>

    <!-- 综合信息弹出框 -->
    <el-dialog
      :title="addDialogTitle"
      :visible.sync="isVisibleComposite"
      width="1200px"
      :modal="false"
    >
      <h4 style="margin: 15px 0">{{ form.NAME }}</h4>
      <el-row :gutter="12">
        <el-col :span="4">
          <el-card shadow="always" style="background-color: #40c46e">
            <div class="ht">客流量</div>
            <div class="hd">20</div>
          </el-card>
        </el-col>
        <el-col :span="4">
          <el-card shadow="always" style="background-color: #40c46e">
            <div class="ht">空气质量</div>
            <div class="hd">优</div>
          </el-card>
        </el-col>
        <el-col :span="4">
          <el-card shadow="always" style="background-color: #4ebbe3">
            <div class="ht">湿度</div>
            <div class="hd">55%</div>
          </el-card>
        </el-col>
        <el-col :span="4">
          <el-card shadow="always" style="background-color: #4ebbe3">
            <div class="ht">温度</div>
            <div class="hd">10℃</div>
          </el-card>
        </el-col>
        <el-col :span="4">
          <el-card shadow="always" style="background-color: #e08662">
            <div class="ht">消耗水量</div>
            <div class="hd">12.84</div>
          </el-card>
        </el-col>
        <el-col :span="4">
          <el-card shadow="always" style="background-color: #e08662">
            <div class="ht">消耗电量</div>
            <div class="hd">36.69</div>
          </el-card>
        </el-col>
      </el-row>

      <div class="box">
        <div>
          <h4 style="margin: 15px 0">昨日每小时人流量统计</h4>
          <div
            class="one"
            style="width: 550px; height: 400px; background: #fff"
            id="dyclyhLinedivF1"
          ></div>
        </div>
        <div>
          <h4 style="margin: 15px 0">昨日每小时气体监测</h4>
        <div
          class="two"
          style="width: 550px; height: 400px; background: #fff"
          id="dyclyhLinedivQ"
        ></div>
        </div>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import eventBus from '@/eventBus.js'

import export2Excel from '@/utils/exportExcel/index.js'
import OSS from 'ali-oss';
import { time } from 'echarts';


import * as echarts from 'echarts';
export default {
  data () {

    return {
      dialogVisible: false,
      clientData: [],
      currentPage: 1, //初始页
      pageSize: 10,    //    每页的数据
      originalData: [],
      tableData: [],
      expireData: [
        { expireTitle: '是' },
        { expireTitle: '否' },
      ],
      select: {
        name: ''
      },
      isVisibleFlowrate: false,
      isVisibleComposite: false,
      isVisibleEdit: false,
      showBigDialogDate: true,
      selectClientInfoList: [],
      TYPEdate: [
        { TYPEltitle: '独立式公厕' },
        { TYPEltitle: '附件式公厕' },
        { TYPEltitle: '移动式公厕' },
      ],
      LEVELdate: [
        { LEVELltitle: '一类' },
        { LEVELltitle: '二类' },
        { LEVELltitle: '三类' },
        { LEVELltitle: '生态' },
        { LEVELltitle: '临时' },
        { LEVELltitle: '非标准' },
      ],
      rolelevel: [{
        roleleveltitle: '公司',
        rolelevelindex: '-1'
      }, {
        roleleveltitle: '项目',
        rolelevelindex: '0'
      }, {
        roleleveltitle: '机扫',
        rolelevelindex: '1'
      }, {
        roleleveltitle: '垃圾',
        rolelevelindex: '2'
      }, {
        roleleveltitle: '人工',
        rolelevelindex: '3'
      }, {
        roleleveltitle: '公厕维保',
        rolelevelindex: '4'
      }],
      form: {
        DW: "",
        CPH: "",
        MODEL: "",
        PERSON: "",
        BUYTIME: "",
        EXPLAIN: "",
        USEDEPTNAME: "",
        USEDEPTID: "",
        VOWNER: "",
        BRAND: "",
        VIN: "",
        ENGINENUM: "",
        DISCHARGERATE: "",
        VCONDITION: "",
        PRICE: "",
        CLIENT_NO: [],
        USE: "",
      },
      showBigDialogVisible: false,
      srcBig: '',
      //图片上传
      fileList: [],
      PHOTOUrl: '', //存上传后的公厕图片url
      CBPicUrl: '', //存上传后的车本图片url
      dataObj: {
        region: 'oss-cn-beijing',//我的存储是北京，可根据具体配置自行修改
        accessKeyId: 'LTAISI12uxTRFccz',
        accessKeySecret: 'cQAvLIZ9JizT5RXRNPBVcXfg3iURD8',
        bucket: 'photo-srw-hb2',
      }, //存签名信息
      baseAli: 'oss-cn-beijing.aliyuncs.com',
    }
  },
  created () {
    eventBus.$on('mapClick_ToiletDetail', val => {
      console.log(val)
      var row = this.originalData.filter(item => item.ID === val)[0]
      this.handleEdit(0, row)
      // this.Data.arrayToiletData = val
      // this.mapOperationsList[0].num = val.length
      // this.handleCheckToilet()
    })
    if (localStorage.getItem('CTYPE') == '0') {
      this.rolelevel.shift()
    } else if (localStorage.getItem('CTYPE') != '-1') {
      this.rolelevel = []
    }
    this.getClientRoleList()
  },
  mounted () {
    this.getlistdata()
    // this.dyclyhLineSearchClick()
    // this.dyclyhLineSearchClick1()
  },
  methods: {
    //获取公厕列表
    async getlistdata () {
      var url = '/CarService/getPlaceToilet?CLIENT_NO=' + localStorage.getItem('CLIENT_NO')
      const { data } = await this.$Http.get(url)
      this.originalData = data
      this.screeningData()
    },
    // 获取组织机构名
    async getClientRoleList () {
      var url = '/CarService/getAbleAddPlaceInfo?CLIENT_NO=' + localStorage.getItem('CLIENT_NO')
      const { data } = await this.$Http.get(url)
      this.selectClientInfoList = data
    },
    // 给组织机构名称下拉列表传值
    changClient (e) {
      this.form.CLIENT_NO_select = ''
      this.getClientRoleList(e)
    },
    change (e) {
      this.$forceUpdate()
    },
    // 导入Excel
    onChange (file, fileList) {
      //  console.log(fileList);
      this.fileData = file; // 保存当前选择文件
      this.readExcel(); // 调用读取数据的方法
    },
    // 读取数据
    readExcel (e) {
      let that = this;
      const files = that.fileData;
      console.log(files);
      if (!files) {
        //如果没有文件
        return false;
      } else if (!/\.(xls|xlsx)$/.test(files.name.toLowerCase())) {
        this.$message.error("上传格式不正确，请上传xls或者xlsx格式");
        return false;
      }
      const fileReader = new FileReader();
      console.log(fileReader)
      fileReader.onload = ev => {
        try {
          const data = ev.target.result;
          //  console.log(ev.target)
          //  console.log(this);
          const workbook = this.XLSX.read(data, {
            type: "binary"// 以字符编码的方式解析
          });

          if (workbook.SheetNames.length >= 1) {
            //  this.$message({
            //    message: "导入数据表格成功",
            //    showClose: true,
            //    type: "success"
            //  });

            const wsname = workbook.SheetNames[0]; //取第一张表
            const ws = this.XLSX.utils.sheet_to_json(workbook.Sheets[wsname]); //生成json表格内容
            console.log(ws)
            this.inputExcelDataLength = ws.length
            this.fullscreenLoading = this.$loading({
              lock: true,
              text: 'Loading',
              spinner: 'el-icon-loading',
              background: 'rgba(0, 0, 0, 0.7)'
            })
            for (let i = 0, len = ws.length; i < len; i++) {
              var item = ws[i]
              //   var sheetData = {
              //     VID: item['居民电话'],
              //     RUBBISH_NAME: item["垃圾品名"],
              //     WEIGHT: item["垃圾称重"],
              //     photo: '',
              //     LONGITUDE: 0,
              //     LATITUDE: 0
              //   }
              //   let exceldata =  []
              //   exceldata.push(sheetData)
              this.addWeight(item)
            }
          } else {
            this.$message.error("未读取到表格内容");
          }
        } catch (e) {
          return false;
        }
      };
      // 如果为原生 input 则应是 files[0]
      fileReader.readAsBinaryString(files.raw);
    },
    async addWeight (item) {
      this.$axios({
        url: 'CarService/AddPlaceToilet',
        method: 'post',
        data: {
          NAME: item['公厕名称'],
          LONGITUDE: item['经度'],
          LATITUDE: item['纬度'],
          LOCATION: item['位置'],
          CLIENT_NO: item['区域ID'],
        }
      }).then(res => {
        console.log(res)
        this.inputExcelDataIndex++
        if (res.data.IsSucess) {
          this.fullscreenLoading.close()
          this.$message.success('表格文件导入成功')
          this.getlistdata()
        } else {
          this.fullscreenLoading.close()
          this.$message.error('表格文件导入失败' + '，' + res.data.Message);

        }
        if (this.inputExcelDataIndex == this.inputExcelDataLength) {
          this.fullscreenLoading.close()
          if (this.strError.length == 0) {
            this.$message.success('表格文件导入成功')
          } else {
            // this.$message.error('表格文件导入结束<br/>' + this.strError);
            this.$message({
              message: '表格文件导入结束，' + this.strError,
              type: 'error',
              duration: 5000
            })
          }
          this.getlistdata()
        }
      })
      //   })
    },
    // 导出Excel
    exportExcel () {
      let excelName = '公厕基本信息'
      const tHeader = ['公厕编号', '公厕名称', '经度', '纬度', '位置', '区域ID']
      const filterVal = ['ID', 'NAME', 'LONGITUDE', 'LATITUDE', 'LOCATION', 'CLIENT_NO']
      export2Excel(tHeader, filterVal, this.tableData, excelName)
    },
    // 打开新增窗口
    handleAdd () {
      this.addDialogTitle = '新增公厕信息'
      //清空编辑框
      this.form = {}
      //展示窗口
      this.isVisibleEdit = true;
      this.idEdit = false;
    },
    // 打开编辑窗口
    handleEdit (index, row) {
      this.form = Object.assign({}, row);
      this.form.CLIENT_NO_select = this.form.USERNAME
      this.addDialogTitle = '编辑公厕信息'
      this.isVisibleEdit = true;
      this.idEdit = true;
    },
    // 点击保存，判断是新增还是编辑操作
    handleSubmit () {
      if (this.addDialogTitle == '新增公厕信息') {
        this.saveAdd()
      } else {
        this.saveEdit()
      }
    },
    // 新增保存
    async saveAdd () {
      // console.log(this.addform)
      this.$axios({
        url: 'CarService/AddPlaceToilet',
        method: 'post',
        data: {
          NAME: this.form.NAME,
          LONGITUDE: this.form.LONGITUDE,
          LATITUDE: this.form.LATITUDE,
          LOCATION: this.form.LOCATION,
          CLIENT_NO: this.form.CLIENT_NO,
        },

      }).then((res) => {
        console.log(this.data)
        console.log(res)
        if (res.data.IsSucess) {
          this.$message.success('新增成功');
          this.isVisibleEdit = false
          this.getlistdata()
        } else {
          this.$message.error('新增失败');
        }
      })

    },
    // 保存编辑
    async saveEdit () {
      let PATH = ''
      if (this.PHOTOUrl === '') {
        //未做选择修改
        PATH = this.form.PHOTO
      } else {
        PATH = this.PHOTOUrl
      }
      this.$axios({
        url: 'CarService/UpdataPlaceToilet',
        method: 'post',
        data: {
          ID: this.form.ID,
          NAME: this.form.NAME,
          LONGITUDE: this.form.LONGITUDE,
          LATITUDE: this.form.LATITUDE,
          LOCATION: this.form.LOCATION,
          CLIENT_NO: this.form.CLIENT_NO,
          LEVEL: this.form.LEVEL,
          TYPE: this.form.TYPE,
          TIME: this.form.TIME,
          MDBSL: this.form.MDBSL,
          MZBSL: this.form.MZBSL,
          XBC: this.form.XBC,
          FDBSL: this.form.FDBSL,
          FZBSL: this.form.FZBSL,
          BABYROOM: this.form.BABYROOM,
          FREEROOM: this.form.FREEROOM,
          AREA: this.form.AREA,
          CREATE_TIME: this.form.CREATE_TIME,
          UPDATE_TIME: this.form.UPDATE_TIME,
          REMARK: this.form.REMARK,
          PHOTO: PATH,
        },

      }).then((res) => {
        console.log(this.data)
        console.log(res)
        if (res.data.IsSucess) {
          this.$message.success('编辑成功');
          this.isVisibleEdit = false
          this.getlistdata()
        } else {
          this.$message.error('编辑失败');
        }
      })
    },
    // 删除公厕信息
    async handleDelete (index, row) {
      const confirmResult = await this.$confirm('确定删除？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).catch(err => err)
      if (confirmResult == 'confirm') {
        const params = {
          ID: row.ID,
        }
        const { data } = await this.$Http.get('CarService/DeletePlaceToilet', { params })
        if (data.IsSucess) {
          this.$message.success('删除成功')
          this.isVisibleEdit = false
          this.getlistdata()
        } else {
          this.$message.error('删除失败');
        }
      } else {
        this.$message.info('取消删除')
        this.isVisibleEdit = false
      }

    },
    // 模糊查询
    screeningData () {
      this.currentPage = 1;
      this.tableData = [];
      // this.tableData = this.originalData
      // if (this.select.name) this.tableData = this.tableData.filter(item => item.NAME.includes(this.select.name))
      // console.log(this.select.name)
      var listDuli = [], listFujian = [], listYidong = [];
      this.originalData.forEach(item => {
        if (!item.NAME.includes(this.select.name)) {
          return;
        }
        switch (item.TYPE) {
          case '独立式公厕':
            item.img = 'duli'
            listDuli.push(item);
            break;
          case '附建式公厕':
            item.img = 'fujian'
            listFujian.push(item);
            break;
          case '移动式公厕':
            item.img = 'yidong'
            listYidong.push(item);
            break;
        }
        this.tableData.push(item);
      });
      // eventBus.$emit('mapData_Toilet', this.tableData)
      eventBus.$emit('mapData_Toilet', [listDuli, listFujian, listYidong])
    },

    // 分页导航
    handlePageChange (currentPage) {
      this.currentPage = currentPage;
      // console.log(this.currentPage)
      // this.$set(this.query, 'pageIndex', val);
      // this.getlistdata();
    },
    handleSizeChange (size) {
      this.pageSize = size;
      console.log(this.pageSize)
    },
    // 放大图片
    bigImage (row) {
      this.srcBig = row.PHOTO
      this.showBigDialogVisible = true
    },
    handleClose () {
      this.showBigDialogVisible = false;
    },
    // 限制用户上传的图片格式和大小
    beforeAvatarUpload (file) {
      const isJPG = file.type === 'image/jpeg';
      const isLt2M = file.size / 1024 / 1024 < 2
      if (!isJPG) {
        this.$message.error('上传头像图片只能是 JPG 格式!');
      }
      if (!isLt2M) {
        this.$message.error('上传头像图片大小不能超过 2MB!');
      }
      return isJPG && isLt2M;
    },
    // 点击上传公厕图片按钮
    clickVehicle () {
      this.$refs.VehicleFile.click();

    },
    changeVehicle () {
      this.afterRead1(this.$refs.VehicleFile.files[0]);
      this.$refs.VehicleFile.value = null; // 移除文件，可以保证上传同样的文件时，也会触发change事件
    },
    // 上传公厕图片
    afterRead1 (file) {
      return new Promise((resolve, reject) => {
        // 此时可以自行将文件上传至服务器
        const that = this
        let client = new OSS(this.dataObj)
        const fileName = file.name
        //定义唯一的文件名，打印出来的uid其实就是时间戳
        //client 是第一步中的 client
        client
          .multipartUpload(fileName, file)
          .then((result) => {
            //下面是如果对返回结果再进行处理，根据项目需要
            // console.log(result)
            that.PHOTOUrl =
              'http://' +
              result.bucket +
              '.' +
              that.baseAli +
              '/' +
              result.name
            console.log(that.PHOTOUrl)
            resolve()
          })
          .catch((err) => {
            console.log('err:', err)
            reject()
          })
      })
    },
    // 双击表格某一行
    dblClickRow (row) {
      eventBus.$emit('mapDBrowToilet', row)
    },
    // 打开有害气体监测曲线
    // openLine () {
    //   if(this.echartLine){
    //     this.echartLine.clear()
    //   }
    //   this.dyclyhLineSearchClick();
    //   this.dialogVisible = true;
    // },
    flowrateClick (index, row) {
      // 进入流量分析页面
      this.form = Object.assign({}, row);
      this.addDialogTitle = '流量分析'
      this.isVisibleFlowrate = true;
      this.dyclyhLineSearchClick1()
    },
    SearchClick (index, row) {
      // 进入气体监测页面
      this.form = Object.assign({}, row);
      // this.addDialogTitle = '流量分析'
      this.dialogVisible = true;
      this.dyclyhLineSearchClick()
    },
    compositeClick (index, row) {
      // 进入综合信息页面
      this.form = Object.assign({}, row);
      this.addDialogTitle = '综合信息'
      this.isVisibleComposite = true;
      this.dyclyhLineSearchClickF()
      this.dyclyhLineSearchClickQ()
    },
    // 绘制客流量曲线
    async dyclyhLineSearchClick1 () {
      // this.isVisibleFlowrate = true;
      // if (this.echartLine) {
      //   this.echartLine.clear()
      // }
      setTimeout(() => {
        // 绘制图表
        this.echartLine = echarts.init(document.getElementById('dyclyhLinedivF'));
        this.echartLine.setOption(
          {
            color: ["#409eff", "#ffdb5c", "#91cc75", "#fac858"],
            legend: {
              top: '3%',
              data: ['每小时人流量']
            },
            grid: {
              left: '3%',
              right: '4%',
              bottom: '3%',
              containLabel: true
            },

            tooltip: {
              trigger: 'axis'
            },
            xAxis: {
              type: 'category',
              data: [
                '1时', '2时', '3时', '4时', '5时', '6时', '7时', '8时', '9时', '10时', '11时', '12时',
                '13时', '14时', '15时', '16时', '17时', '18时', '19时', '20时', '21时', '22时', '23时', '24时'
              ]
            },
            yAxis: {
              type: 'value'
            },
            series: [{
              barWidth: '15',
              name: '每小时人流量',
              type: 'bar',
              itemStyle: {
                normal: {
                  // 柱体显示数字
                  label: {
                    show: true, //开启显示数值
                    position: 'top', //数值在上方显示
                    textStyle: {  //数值样式
                      color: '#000',   //字体颜色
                      fontSize: 10  //字体大小
                    }
                  },

                }
              },
              stack: 'Total',
              data: [
                '3', '2', '2', '3', '5', '8', '7', '16', '12', '7', '9', '20',
                '15', '8', '6', '21', '12', '15', '3', '4', '3', '2', '3', '2', '3'
              ]
            },]
          });
      }, 2000)
    },
    // 绘制客流量曲线
    async dyclyhLineSearchClickF () {
      // this.isVisibleFlowrate = true;
      // if (this.echartLineF) {
      //   this.echartLineF.clear()
      // }
      setTimeout(() => {
        // 绘制图表
        this.echartLineF = echarts.init(document.getElementById('dyclyhLinedivF1'));
        this.echartLineF.setOption(
          {
            color: ["#409eff", "#ffdb5c", "#91cc75", "#fac858"],
            legend: {
              top: '3%',
              data: ['每小时人流量']
            },
            grid: {
              left: '3%',
              right: '4%',
              bottom: '3%',
              containLabel: true
            },

            tooltip: {
              trigger: 'axis'
            },
            xAxis: {
              type: 'category',
              data: [
                '1时', '2时', '3时', '4时', '5时', '6时', '7时', '8时', '9时', '10时', '11时', '12时',
                '13时', '14时', '15时', '16时', '17时', '18时', '19时', '20时', '21时', '22时', '23时', '24时'
              ]
            },
            yAxis: {
              type: 'value'
            },
            series: [{
              barWidth: '15',
              name: '每小时人流量',
              type: 'bar',
              itemStyle: {
                normal: {
                  // 柱体显示数字
                  label: {
                    show: true, //开启显示数值
                    position: 'top', //数值在上方显示
                    textStyle: {  //数值样式
                      color: '#000',   //字体颜色
                      fontSize: 10  //字体大小
                    }
                  },

                }
              },
              stack: 'Total',
              data: [
                '3', '2', '2', '3', '5', '8', '7', '16', '12', '7', '9', '20',
                '15', '8', '6', '21', '12', '15', '3', '4', '3', '2', '3', '2', '3'
              ]
            },]
          });
      }, 2000)
    },
    // 绘制有害气体曲线
    async dyclyhLineSearchClick () {
      // this.dialogVisible = true;
      // if (this.echartLine) {
      //   this.echartLine.clear()
      // }
      setTimeout(() => {
        // 绘制图表
        this.echartLine = echarts.init(document.getElementById('dyclyhLinediv'));
        this.echartLine.setOption(
          {

            legend: {
              top: '3%',
              data: ['硫化氢 mg/m³', '臭氧 mg/m³', '氨气 mg/m³']
            },
            grid: {
              left: '3%',
              right: '4%',
              bottom: '3%',
              containLabel: true
            },

            tooltip: {
              trigger: 'axis'
            },
            xAxis: {
              type: 'category',
              data: [
                '1时', '2时', '3时', '4时', '5时', '6时', '7时', '8时', '9时', '10时', '11时', '12时',
                '13时', '14时', '15时', '16时', '17时', '18时', '19时', '20时', '21时', '22时', '23时', '24时'
              ]
            },
            yAxis: {
              type: 'value'
            },
            series: [{
              name: '硫化氢 mg/m³',
              type: 'line',
              stack: 'Total',
              data: [
                '0.001', '0.002', '0.002', '0.002', '0.002', '0.005', '0.006', '0.004', '0.003', '0.003', '0.002', '0.002',
                '0.002', '0.003', '0.002', '0.002', '0.001', '0.002', '0.002', '0.001', '0.001', '0.001', '0.002', '0.000', '0.000'
              ]
            }, {
              name: '臭氧 mg/m³',
              type: 'line',
              stack: 'Total',
              data: [
                '0.03', '0.06', '0.04', '0.09', '0.08', '0.07', '0.05', '0.06', '0.04', '0.03', '0.05', '0.06',
                '0.05', '0.03', '0.03', '0.03', '0.01', '0.03', '0.03', '0.04', '0.03', '0.02', '0.03', '0.03', '0.03'
              ]
            }, {
              name: '氨气 mg/m³',
              type: 'line',
              stack: 'Total',
              data: [
                '0.03', '0.02', '0.02', '0.03', '0.05', '0.08', '0.07', '0.16', '0.12', '0.13', '0.14', '0.10',
                '0.15', '0.08', '0.06', '0.07', '0.05', '0.02', '0.03', '0.04', '0.03', '0.02', '0.03', '0.02', '0.03'
              ]
            },]
          });
      }, 2000)
    },
    // 绘制有害气体曲线
    async dyclyhLineSearchClickQ () {
      // this.dialogVisible = true;
      // if (this.echartLine) {
      //   this.echartLine.clear()
      // }
      setTimeout(() => {
        // 绘制图表
        this.echartLine = echarts.init(document.getElementById('dyclyhLinedivQ'));
        this.echartLine.setOption(
          {

            legend: {
              top: '3%',
              data: ['硫化氢 mg/m³', '臭氧 mg/m³', '氨气 mg/m³']
            },
            grid: {
              left: '3%',
              right: '4%',
              bottom: '3%',
              containLabel: true
            },

            tooltip: {
              trigger: 'axis'
            },
            xAxis: {
              type: 'category',
              data: [
                '1时', '2时', '3时', '4时', '5时', '6时', '7时', '8时', '9时', '10时', '11时', '12时',
                '13时', '14时', '15时', '16时', '17时', '18时', '19时', '20时', '21时', '22时', '23时', '24时'
              ]
            },
            yAxis: {
              type: 'value'
            },
            series: [{
              name: '硫化氢 mg/m³',
              type: 'line',
              stack: 'Total',
              data: [
                '0.001', '0.002', '0.002', '0.002', '0.002', '0.005', '0.006', '0.004', '0.003', '0.003', '0.002', '0.002',
                '0.002', '0.003', '0.002', '0.002', '0.001', '0.002', '0.002', '0.001', '0.001', '0.001', '0.002', '0.000', '0.000'
              ]
            }, {
              name: '臭氧 mg/m³',
              type: 'line',
              stack: 'Total',
              data: [
                '0.03', '0.06', '0.04', '0.09', '0.08', '0.07', '0.05', '0.06', '0.04', '0.03', '0.05', '0.06',
                '0.05', '0.03', '0.03', '0.03', '0.01', '0.03', '0.03', '0.04', '0.03', '0.02', '0.03', '0.03', '0.03'
              ]
            }, {
              name: '氨气 mg/m³',
              type: 'line',
              stack: 'Total',
              data: [
                '0.03', '0.02', '0.02', '0.03', '0.05', '0.08', '0.07', '0.16', '0.12', '0.13', '0.14', '0.10',
                '0.15', '0.08', '0.06', '0.07', '0.05', '0.02', '0.03', '0.04', '0.03', '0.02', '0.03', '0.02', '0.03'
              ]
            },]
          });
      }, 2000)
    },
  }
}
</script>
<style>
.container {
  overflow-y: auto;
  height: calc(100% - 50px);
  border: 0px;
}
.el-col-6 {
  min-width: 400px;
  min-height: 50px;
}
.el-table th {
  height: 25px;
}
.el-form-item label {
  width: 80px;
}

.el-card {
  /* background-color: rgba(46, 125, 190, 0.75); */
  text-align: center;
}
.ht {
  color: #fff;
  font-size: 15px;
  font-weight: bolder;
  line-height: 25px;
}
.hd {
  color: #fff;
  font-size: 30px;
  font-weight: bolder;
  line-height: 40px;
}

.box {
  grid-auto-flow: row dense;
  display: grid;
  grid-template-columns: repeat(2, 50%);
  /* grid-template-rows: repeat(2, 50%); */
  grid-template-areas: 'one two';
}
.one {
  margin: 5px;
  grid-area: one;
}

.two {
  margin: 5px;
  grid-area: two;
}
.three {
  margin: 5px;
  grid-area: three;
}
.four {
  margin: 5px;
  grid-area: four;
}
/* .el-upload--text {
  width: 300px;
} */
</style>